<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Rails::Paths::Path</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../css/github.css" type="text/css" media="screen" />
<script src="../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Class</span> 
            Rails::Paths::Path 
            
                <span class="parent">&lt; 
                    
                    <a href="../../Object.html">Object</a>
                    
                </span>
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../files/railties/lib/rails/paths_rb.html">railties/lib/rails/paths.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>#</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-3C-3C">&lt;&lt;</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>C</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-children">children</a>,
              </li>
            
              
              <li>
                <a href="Path.html#method-i-concat">concat</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-each">each</a>,
              </li>
            
              
              <li>
                <a href="Path.html#method-i-existent">existent</a>,
              </li>
            
              
              <li>
                <a href="Path.html#method-i-existent_directories">existent_directories</a>,
              </li>
            
              
              <li>
                <a href="Path.html#method-i-expanded">expanded</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-first">first</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>L</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-last">last</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-c-new">new</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>P</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-push">push</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>T</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-to_a">to_a</a>,
              </li>
            
              
              <li>
                <a href="Path.html#method-i-to_ary">to_ary</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>U</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Path.html#method-i-unshift">unshift</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  
    <!-- Includes -->
    <div class="sectiontitle">Included Modules</div>
    <ul>
      
        <li>
          
            <a href="../../Enumerable.html">
              Enumerable
            </a>
          
        </li>
      
    </ul>
  



  

    

    

    


    
      <!-- Section attributes -->
      <div class="sectiontitle">Attributes</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class='attr-rw'>
              [RW]
            </td>
            <td class='attr-name'>glob</td>
            <td class='attr-desc'></td>
          </tr>
        
      </table>
    


    <!-- Methods -->
    
      <div class="sectiontitle">Class Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-c-new">
            
              <b>new</b>(root, current, paths, options = {})
            
            <a href="Path.html#method-c-new" name="method-c-new" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-c-new_source')" id="l_method-c-new_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L120" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-c-new_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 120</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">initialize</span>(<span class="ruby-identifier">root</span>, <span class="ruby-identifier">current</span>, <span class="ruby-identifier">paths</span>, <span class="ruby-identifier">options</span> = {})
  <span class="ruby-ivar">@paths</span>    = <span class="ruby-identifier">paths</span>
  <span class="ruby-ivar">@current</span>  = <span class="ruby-identifier">current</span>
  <span class="ruby-ivar">@root</span>     = <span class="ruby-identifier">root</span>
  <span class="ruby-ivar">@glob</span>     = <span class="ruby-identifier">options</span>[<span class="ruby-value">:glob</span>]

  <span class="ruby-identifier">options</span>[<span class="ruby-value">:autoload_once</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">autoload_once!</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">skip_autoload_once!</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:eager_load</span>]    <span class="ruby-operator">?</span> <span class="ruby-identifier">eager_load!</span>    <span class="ruby-operator">:</span> <span class="ruby-identifier">skip_eager_load!</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:autoload</span>]      <span class="ruby-operator">?</span> <span class="ruby-identifier">autoload!</span>      <span class="ruby-operator">:</span> <span class="ruby-identifier">skip_autoload!</span>
  <span class="ruby-identifier">options</span>[<span class="ruby-value">:load_path</span>]     <span class="ruby-operator">?</span> <span class="ruby-identifier">load_path!</span>     <span class="ruby-operator">:</span> <span class="ruby-identifier">skip_load_path!</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                  
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-3C-3C">
            
              <b>&lt;&lt;</b>(path)
            
            <a href="Path.html#method-i-3C-3C" name="method-i-3C-3C" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Path.html#method-i-push">push</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-3C-3C_source')" id="l_method-i-3C-3C_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L166" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-3C-3C_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 166</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">&lt;&lt;</span>(<span class="ruby-keyword ruby-title">path</span>)
  <span class="ruby-ivar">@paths</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">path</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-children">
            
              <b>children</b>()
            
            <a href="Path.html#method-i-children" name="method-i-children" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-children_source')" id="l_method-i-children_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L132" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-children_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 132</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">children</span>
  <span class="ruby-identifier">keys</span> = <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span><span class="ruby-operator">|</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@current</span>) }
  <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-ivar">@current</span>)
  <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">values_at</span>(*<span class="ruby-identifier">keys</span>.<span class="ruby-identifier">sort</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-concat">
            
              <b>concat</b>(paths)
            
            <a href="Path.html#method-i-concat" name="method-i-concat" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-concat_source')" id="l_method-i-concat_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L171" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-concat_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 171</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">concat</span>(<span class="ruby-identifier">paths</span>)
  <span class="ruby-ivar">@paths</span>.<span class="ruby-identifier">concat</span> <span class="ruby-identifier">paths</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-each">
            
              <b>each</b>(&amp;block)
            
            <a href="Path.html#method-i-each" name="method-i-each" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-each_source')" id="l_method-i-each_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L162" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-each_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 162</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">each</span>(&amp;<span class="ruby-identifier">block</span>)
  <span class="ruby-ivar">@paths</span>.<span class="ruby-identifier">each</span>(&amp;<span class="ruby-identifier">block</span>)
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-existent">
            
              <b>existent</b>()
            
            <a href="Path.html#method-i-existent" name="method-i-existent" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Returns all expanded paths but only if they exist in the filesystem.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-existent_source')" id="l_method-i-existent_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L205" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-existent_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 205</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">existent</span>
  <span class="ruby-identifier">expanded</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">f</span>) }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-existent_directories">
            
              <b>existent_directories</b>()
            
            <a href="Path.html#method-i-existent_directories" name="method-i-existent_directories" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-existent_directories_source')" id="l_method-i-existent_directories_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L209" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-existent_directories_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 209</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">existent_directories</span>
  <span class="ruby-identifier">expanded</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">d</span>) }
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-expanded">
            
              <b>expanded</b>()
            
            <a href="Path.html#method-i-expanded" name="method-i-expanded" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Expands all paths against the root and return all unique values.</p>
            </div>
          
          
          
            <div class="aka">
              Also aliased as: <a href="Path.html#method-i-to_a">to_a</a>
            </div>
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-expanded_source')" id="l_method-i-expanded_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L184" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-expanded_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 184</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">expanded</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;You need to set a path root&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">path</span>
  <span class="ruby-identifier">result</span> = []

  <span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">path</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">p</span>, <span class="ruby-ivar">@root</span>.<span class="ruby-identifier">path</span>)

    <span class="ruby-keyword">if</span> <span class="ruby-ivar">@glob</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">path</span>)
      <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-identifier">path</span>) <span class="ruby-keyword">do</span>
        <span class="ruby-identifier">result</span>.<span class="ruby-identifier">concat</span>(<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">glob</span>(<span class="ruby-ivar">@glob</span>).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span> <span class="ruby-identifier">path</span>, <span class="ruby-identifier">file</span> }.<span class="ruby-identifier">sort</span>)
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">path</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">result</span>.<span class="ruby-identifier">uniq!</span>
  <span class="ruby-identifier">result</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-first">
            
              <b>first</b>()
            
            <a href="Path.html#method-i-first" name="method-i-first" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-first_source')" id="l_method-i-first_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L138" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-first_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">first</span>
  <span class="ruby-identifier">expanded</span>.<span class="ruby-identifier">first</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-last">
            
              <b>last</b>()
            
            <a href="Path.html#method-i-last" name="method-i-last" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-last_source')" id="l_method-i-last_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L142" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-last_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 142</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">last</span>
  <span class="ruby-identifier">expanded</span>.<span class="ruby-identifier">last</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-push">
            
              <b>push</b>(path)
            
            <a href="Path.html#method-i-push" name="method-i-push" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_a">
            
              <b>to_a</b>()
            
            <a href="Path.html#method-i-to_a" name="method-i-to_a" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-to_ary">
            
              <b>to_ary</b>()
            
            <a href="Path.html#method-i-to_ary" name="method-i-to_ary" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-to_ary_source')" id="l_method-i-to_ary_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L179" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-to_ary_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 179</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">to_ary</span>
  <span class="ruby-ivar">@paths</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-unshift">
            
              <b>unshift</b>(path)
            
            <a href="Path.html#method-i-unshift" name="method-i-unshift" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-unshift_source')" id="l_method-i-unshift_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/9d9b22f47a1928bf2fde3b7b574e3d8d4b1cca92/railties/lib/rails/paths.rb#L175" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-unshift_source" class="dyn-source">
                <pre><span class="ruby-comment"># File railties/lib/rails/paths.rb, line 175</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">unshift</span>(<span class="ruby-identifier">path</span>)
  <span class="ruby-ivar">@paths</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-identifier">path</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    